#!/bin/bash
read -p "请您输入对应的网卡名字: " net
ipconfig=`ifconfig $net 2>/dev/null|awk 'NR==2 {print $2}'`
ifconfig $net >/dev/null 2>&1
if [ $? -eq 0 ];then
       echo "您输入的网卡IP地址为：$ipconfig"
else
       echo "请您正确输入对应的网卡名字"
       exit 1
fi
